import React, { PureComponent } from "react";
import { connect } from "react-redux";
import {getUser,actions} from '../../store/modules/register'
import {bindActionCreators} from 'redux'
class Register extends PureComponent {
  render() {
    let {
        user: { phone, password, nickname },
        register:{
          changeUser,
          reqRegister
        },
        history
      } = this.props;
    //   console.log(this.props)
    return (
        <div>
      <div>
         手机号：
          <input type="text" value={phone} onChange={(e)=>changeUser('phone',e.target.value)} />
        </div>
        <div>
          昵称：
          <input type="text" value={nickname}  onChange={(e)=>changeUser('nickname',e.target.value)} />
        </div>
        <div>
          密码: <input type="text" value={password}  onChange={(e)=>changeUser('password',e.target.value)} />
        </div>
        <button onClick={()=>reqRegister(history)}>注册</button>
      </div>
    );
  }
}
let mapStateToProps=(state)=>({
    user:getUser(state)
});
let mapDispatchToProps=(dispatch)=>({
   register:bindActionCreators(actions,dispatch)
})
export default connect(mapStateToProps,mapDispatchToProps)(Register);
